/*
 * 分享内容到各大社区
 * author 胖胖吉
 * email 317365887@qq.com
*/
var lin_snsShare={
	setting:{
		linkURL:'http://www.0773linji.com',
		title:'林氏智造-专注网站建设,关注PHP开发,前端开发,网站运维,用户体验的专业博客',
		windowName:'share',
		pic:'',//指定选中的图片
		sinaAppKey:'',
		sinaUid:'',
		qqAppKey:''
	},
	setSinaApp:function(sinaAppKey,sinaUid){
		this.setting.sinaAppKey=sinaAppKey||this.setting.sinaAppKey;
		this.setting.sinaUid=sinaUid||this.setting.sinaUid;
	},
	setQQApp:function(qqAppKey){
		this.setting.qqAppKey=qqAppKey||this.setting.qqAppKey;
	},	
	init:function(type,param){
		this.setting.linkURL=param.linkURL||this.setting.linkURL;
		this.setting.linkURL=encodeURIComponent(this.setting.linkURL);
		this.setting.title=param.title||this.setting.title;
		this.setting.pic=param.pic||this.setting.pic;
		this.selectTypeAndGo(type);
	},
	selectTypeAndGo:function(type){
			var params='';
			var url='';
			switch(type)
			{
				case 'qq':	
					url='http://share.v.t.qq.com/index.php?c=share&a=index&url=' + this.setting.linkURL + '&pic=' + this.setting.pic +  '&title=' + this.setting.title +  '&appkey='+this.setting.qqAppKey;
					params = this.getParamsOfShareWindow(634, 468);		
				break;
				case 'zone':
					url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + this.setting.linkURL + '&title=' + this.setting.title +  '&pics='+this.setting.pic;
					params = this.getParamsOfShareWindow(634, 568);
				break;
				case 'sina':
					url = 'http://service.weibo.com/share/share.php?url=' + this.setting.linkURL + '&appkey=' + this.setting.sinaAppKey + '&title=' + this.setting.title +  '&pic='+this.setting.pic+'&ralateUid=' + this.setting.sinaUid;
					params = this.getParamsOfShareWindow(626, 436);	
				break;
				case 'renren':
					url = 'http://widget.renren.com/dialog/share?resourceUrl=' + this.setting.linkURL + '&title=' + this.setting.title + '&pic='+this.setting.pic;
					params = this.getParamsOfShareWindow(626,736);
				break;
				case 'kaixin':
					url='http://www.kaixin001.com/repaste/share.php?rurl=' + this.setting.linkURL+'&rtitle='+this.setting.title+'&rcontent='+this.setting.title;
					params = this.getParamsOfShareWindow(626,736);
				break;
				case 'douban':
					url = 'http://www.douban.com/recommend/?url=' + this.setting.linkURL+ '&title=' + this.setting.title+'&pic='+this.setting.pic;
					params = this.getParamsOfShareWindow(550, 450);
				break;																					
			}
			window.open(url, this.setting.windowName, params);	
	},
	getParamsOfShareWindow:function(w,h){
		return 'height='+h+',width='+w+',top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no';
	}	
};